RbacCache.get   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
import { Injectable } from '@nestjs/common';
2
import { ICacheRBAC } from '../interfaces/cache.rbac.interface';
3
import * as  NodeCache from 'node-cache';
4
5
@Injectable()
6
export class RbacCache implements ICacheRBAC {
7
    KEY = 'RBAC';
8
    TTL = 0;
9
10
    private readonly cache;
11
12
    constructor() {
13
        this.cache = new NodeCache();
14
    }
15
16
    get(): object | null {
17
        return this.cache.get(this.KEY);
18
    }
19
20
    set(value: object): void {
21
        this.cache.set(this.KEY, value, this.TTL);
22
    }
23
24
    del(): void {
25
        this.cache.del(this.KEY);
26
    }
27
}
28